#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>

int gval = 100;

int main()
{
    printf("父进程开始运行,pid:%d,ppid:%d\n",getpid(),getppid());


    pid_t id = fork();
    if(id == 0)
    {
        while(1)
        {
            printf("子进程：gval=%d,&gval=%p,pid=%d,ppid=%d\n",gval,&gval,getpid(),getppid());
            sleep(1);
            gval += 100;
        }
    }
    else 
    {
        while(1)
        {
            printf("父进程：gval=%d,&gval=%p,pid=%d,ppid=%d\n",gval,&gval,getpid(),getppid());
            sleep(1);
        }
    }


    return 0;
}
